package com.shouxin.attendance.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.shouxin.attendance.service.CheckRun;
import com.shouxin.attendance.utils.ThreadPool;

import org.apache.log4j.Logger;

/**
 * 网络连接自动启动应用
 * Created by Jiang on 2015/11/5.
 */
public class NetworkReceiver extends BroadcastReceiver {

	private static final Logger logger = Logger.getLogger(NetworkReceiver.class);

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
	        logger.debug("Receive ACTION_BOOT_COMPLETED...");
	        ThreadPool.execute(new CheckRun(context.getApplicationContext()));
        } else if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
	        logger.debug("Receive ACTION_BATTERY_CHANGED...");
	        ThreadPool.execute(new CheckRun(context.getApplicationContext()));
        }
    }
}
